/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package main.java.com.giftmemo.ui.main;

import com.alee.laf.optionpane.WebOptionPane;
import com.giftmemo.objects.Gender;
import com.giftmemo.objects.Gift;
import com.giftmemo.objects.Person;
import com.giftmemo.objects.TypeOfRelationship;
import com.giftmemo.objects.impl.PersonImpl;
import com.giftmemo.ui.utils.BasicDialog;
import com.giftmemo.ui.utils.BasicFrame;
import com.giftmemo.ui.utils.ButtonsPanel;
import com.giftmemo.ui.view.ViewFriendsPanel;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import main.java.com.giftmemo.ui.add.AddGiftPanel;

/**
 *
 * @author Egor
 */
public class EntryPoint {

    public static void main(String[] args) {
        final BasicFrame mainFrame = new BasicFrame();
        final BasicDialog addGiftDialog = new BasicDialog(mainFrame);
        addGiftDialog.setLocationRelativeTo(mainFrame);
        final AddGiftPanel addGiftPanel = new AddGiftPanel();
        addGiftDialog.setContent(addGiftPanel);
        ViewFriendsPanel friendsPanel = new ViewFriendsPanel();
        List<Gift> gifts = new ArrayList<>();
        
        addGiftPanel.setAddButtAction(new AbstractAction("Add gift to list") {
            
            @Override
            public void actionPerformed(ActionEvent e) {
                
            }
        });
        
        ButtonsPanel buttonsPanel = new ButtonsPanel(ButtonsPanel.ButtonsPanelState.OK_BUTTON, ButtonsPanel.ButtonsPanelState.CANCEL_BUTTON);
        buttonsPanel.setOkButtonAction(new AbstractAction("Add gift") {

            @Override
            public void actionPerformed(ActionEvent e) {
                addGiftDialog.showDialog();
            }
        });

        buttonsPanel.setCancelButtonAction(new AbstractAction("Cancel") {

            @Override
            public void actionPerformed(ActionEvent e) {

                if (WebOptionPane.showConfirmDialog(mainFrame, "Вы уверены, что хотите выйти?", "Выход", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                    mainFrame.closeFrame();
                }

            }
        });

        List<Person> persons = new ArrayList<>();
        PersonImpl personImpl = new PersonImpl("Test", new Date(), Gender.MALE, TypeOfRelationship.FRIEND, null);
        persons.add(personImpl);
        PersonImpl personImpl1 = new PersonImpl("Test", new Date(), Gender.MALE, TypeOfRelationship.FRIEND, null);
        persons.add(personImpl1);

        friendsPanel.setFrindsList(persons);

        mainFrame.setLocationRelativeTo(null);
        mainFrame.setContent(friendsPanel, buttonsPanel);
        mainFrame.showFrame();

    }
}
